#include "ros/ros.h" //set ros include

#include "std_msgs/String.h"

#include <ecal/ecal.h>
#include <ecal/msg/protobuf/subscriber.h>
#include <ecal/msg/protobuf/publisher.h>

#include "control.pb.h"
#include "communicate.pb.h"
#include "imu.pb.h"
#include "localization.pb.h"

// function of callback for recv the whell speed
void Callback(const MowerProtoPakg::controlMoveOrder& msg) {
    std::vector<uint8_t> sandSerialBuf(10);
    printf(" move driver line speed:%f ", msg.linespeed() );
    ROS_INFO("hello world!");
    // spdlog::info("move driver line speed:{} angle speed:{}", msg.linespeed() ,msg.angularspeed() );

    // p_chassisDevice->produceSerialData(msg.linespeed(), msg.angularspeed(), sandSerialBuf);
    // p_chassisDevice->sandUsartData(sandSerialBuf);
}


int main(int argc, char *argv[]) // main funtion
{
    eCAL::Initialize(argc, argv, "driver Publisher");
    eCAL::Util::EnableLoopback(true); // 启用 eCAL 消息环回，这意味着订阅者将从同一进程的发布者接收消息（默认值 == false）
    // recv protobuf of mower_mv    
    eCAL::protobuf::CSubscriber<MowerProtoPakg::controlMoveOrder> subscriber("chessMessage"); // ! 
    subscriber.AddReceiveCallback(std::bind(Callback, std::placeholders::_2));
    while (eCAL::Ok()) {
        sleep(10);
    }
    eCAL::Finalize();// finalize eCAL API


    //init ros includes
    ros::init(argc,argv,"haha");

    //print hello world 
    ROS_INFO("hello world!");

    return 0;
}
    